#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 100005;

bool isprime[maxn];
int prime[maxn];
int cnt;

void euler() {
	isprime[1] = false;
	for (int i = 2; i <= maxn; ++i) {
		if (isprime[i])
			prime[++cnt] = i;
		for (int j = 1; j <= cnt && i * prime[j] <= maxn; ++j) {
			isprime[i * prime[j]] = false;
			if (i % prime[j] == 0) break;
		}
	}
}

int preSum[maxn];

signed main() {
	euler();
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> preSum[i];
		preSum[i] += preSum[i - 1];
	}

	for (int i = 1; i <= n; i++)
		cout << preSum[i] << endl;

	int ans = -2147483648;
	for (int i = 1; i <= n; i++) {
		if (isprime[i]) {
			for (int j = i; j <= n; j++)
				ans = max(ans, preSum[j] - preSum[j - i]);
		}
	}
	cout << ans;
	return 0;
}
